***************
* This script produces Figure D.1
* Author: Daniel Kopp
***************

clear
clear matrix
clear mata
set more off	
		
* OECD time use database: Data was accessed in November 2019, and the figures refer to the latest year available in 2019.
import delimited "Misc_files\oecd_hours_worked_paid_unpaid_gender.csv", delim(";")

gen 	female = 1 if sex=="Women"
replace female = 0 if sex=="Men"

drop sex

* We have to add Switzerland by hand (data is from the Swiss Statistical Office and refers to the year 2016) 
expand 3 in l
replace female = 0 if  _n==63
replace country_code = 32 				if _n==63 | _n==64
replace country_string="Switzerland"	if _n==63 | _n==64
replace time_unpaid_work 	= 167.14	if (_n==63 | _n==64) & female==0
replace time_paid_work 		= 286.86	if (_n==63 | _n==64) & female==0
replace time_total_work 	= 450		if (_n==63 | _n==64) & female==0
replace time_unpaid_work 	= 269.14	if (_n==63 | _n==64) & female==1
replace time_paid_work 		= 182.57	if (_n==63 | _n==64) & female==1
replace time_total_work 	= 451.71	if (_n==63 | _n==64) & female==1
replace country_abbr="{bf:CHE}" if country_code==32

gen share_unpaid = time_unpaid_work/time_total_work*100

reshape wide share_unpaid time_total_work time_paid_work time_unpaid_work , i(country_code) j(female)		

cap label drop country_lab
label define country_lab	1	"AUS"	///
	2	"AUT"	///
	3	"BEL"	///
	4	"CAN"	///
	5	"DNK"	///
	6	"EST"	///
	7	"FIN"	///
	8	"FRA"	///
	9	"DEU"	///
	10	"GRC"	///
	11	"HUN"	///
	12	"IRL"	///
	13	"ITA"	///
	14	"JPN"	///
	15	"KOR"	///
	16	"LVA"	///
	17	"LTU"	///
	18	"LUX"	///
	19	"MEX"	///
	20	"NLD"	///
	21	"NZL"	///
	22	"NOR"	///
	23	"POL"	///
	24	"PRT"	///
	25	"SVN"	///
	26	"ESP"	///
	27	"SWE"	///
	28	"TUR"	///
	29	"GBR"	///
	30	"USA"	///
	31	"OECD"	///
	32  "CHE"
label values country_code country_lab

* We drop the OECD average
drop if country_code==31 

cap drop sortno
sort share_unpaid0 
gen sortno = _n 
labmask sortno, values(country_abbr) 
		
	 
local msize "medsmall"		
twoway  (rspike share_unpaid0 share_unpaid1 sortno 	if country_code!=32, horizontal lcolor(gray) lwidth(thin)) ///
		(rspike share_unpaid0 share_unpaid1 sortno 	if country_code==32, horizontal lcolor(gray) lpattern(dash) lwidth(thin)) ///
		(scatter sortno share_unpaid0  				if country_code!=32, msymbol(O)   msize(`msize') mcolor(black)  ) ///
		(scatter sortno share_unpaid1  				if country_code!=32, msymbol(O)   msize(`msize') mcolor(gs10)  )    ///
		(scatter sortno share_unpaid0  				if country_code==32, msymbol(O)   msize(`msize') mcolor(black) mfcolor(white) )    ///	
		(scatter sortno share_unpaid1  				if country_code==32, msymbol(O)   msize(`msize') mlcolor(gs10)  mfcolor(white) )   , ///			
		legend(order(3 "Men" 4 "Women") ) 	ylabel(1(1)31, valuelabel labsize(vsmall) nogrid  angle(horizontal))	 ///
		xtitle("Share unpaid work in total work (in %)") ///
		ytitle("") graphregion(color(white)) bgcolor(white)  	
graph export "$results_part_time\figure_d1_unpaid.eps"	, as(eps) replace	
		
		
local msize "medium"		
twoway  (rspike time_total_work0 time_total_work1 sortno if country_code!=32, horizontal lcolor(gray)) ///
		(rspike time_total_work0 time_total_work1 sortno if country_code==32, horizontal lpattern(dash) lcolor(gray)) ///
		(scatter sortno time_total_work0  if country_code!=32, msymbol(O)   msize(`msize') mcolor(black)  ) ///
		(scatter sortno time_total_work1  if country_code!=32, msymbol(O)   msize(`msize') mcolor(gs10)  )    ///
		(scatter sortno time_total_work0  if country_code==32, msymbol(O)   msize(`msize') mcolor(black)  mfcolor(white) )    ///	
		(scatter sortno time_total_work1  if country_code==32, msymbol(O)   msize(`msize') mcolor(gs10)  mfcolor(white) )   , ///			
		legend(order(3 "Men" 4 "Women") ) 	ylabel(1(1)31, valuelabel labsize(vsmall) nogrid  angle(horizontal))	 ///
		xtitle("Total work (minutes per day) ") ///
		ytitle("") graphregion(color(white)) bgcolor(white)  
graph export "$results_part_time\figure_d1_total.eps"	, as(eps) replace	
		
